Ext.define('App.controller.clubType.ClubTypeViewController', {
    extend : 'Ext.app.ViewController',
    alias : 'controller.clubTypeViewController',
    menu : Ext.widget('menu'),
    control : {
        'clubTypeView clubTypeSearch basesearchform' : {
            beforerender : function(form) {
                var buttons = {
                    'bs/clubType/saveClubType' : function(permit) {
                        var name = form.down("[name=typeName]").getValue();
                        if(!name){
                            BaseUtil.toast("请填写俱乐部类型");
                            return;
                        }
                        BaseUtil.post(permit.url,function(data){
                            BaseUtil.toast(data.msg);
                            Ext.StoreMgr.get('clubType.ClubTypeStore').reload();
                        },form.getValues());
                    },
                    'bs/clubType/updateClubType' : function(permit) {
                        var name = form.down("[name=typeName]").getValue();
                        if(!name){
                            BaseUtil.toast("请填写俱乐部类型");
                            return;
                        }
                        BaseUtil.post(permit.url,function(data){
                            BaseUtil.toast(data.msg);
                            Ext.StoreMgr.get('clubType.ClubTypeStore').reload();
                        },form.getValues());
                    }

                };
                BaseUtil.createPermitBar(form, buttons);
            },
            render : function() {
                BaseUtil.loadStore(Ext.StoreMgr.get('clubType.ClubTypeStore'),Ext.getCmp('clubTypeView').down('clubTypeSearch form').getForm().getFieldValues());
            }
        },
        'clubTypeView clubTypeList' : {
            itemclick:function(view, record, item, index, e, eOpts){
                var search  =  Ext.getCmp('clubTypeView').down('clubTypeSearch form');
                search.reset();
                search.loadRecord(record);
            },
        },
        'clubTypeView clubTypeSearch [action=search] ' : {
            click : function() {
                BaseUtil.loadStore(Ext.StoreMgr.get('clubType.ClubTypeStore'),Ext.getCmp('clubTypeView').down('clubTypeSearch form').getForm().getFieldValues());
            }
        }
    }
});